#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repb(i,n) for(int i=n-1; i>=0; i--)
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define REPB(i,a,b) for(int i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define tc(t) int t; cin>>t; while(t--)

#define INF 1145140
//int spcnt;
//bool vis[100005];
//bool visp[100005];
//int ans=114514;

/*void dfs(int cur, int k)
{
	if(viscnt==spcnt)
	{
		ans=min(ans,vispcnt);
		return;
	}
	for(auto i:pcc[cur])
	{
		if(!visp[i])
		{
			for(auto j:pcp[i]) vis[j]=true;
			visp[i]=true;
		}
	}
	return;
}*/

int main()
{
	//#ifndef LOCAL
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	//#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	tc(t)
	{
		int n,m,L,V;
		cin>>n>>m>>L>>V;
		vector<int> d(n),v(n),a(n),p(m);
		set<int> pc;
		vector<long double> x(n);
		vector<vector<int> > pcp(m);
		//pcp.resize(0);pcc.resize(0);
		bool aallzero=true,aallpos=true;
		rep(i,n)
		{
			cin>>d[i]>>v[i]>>a[i];
			if(a[i]<0) x[i]=v[i]*v[i]/(-2.0*a[i]);
			else x[i]=INF;
			if(a[i]<=0) aallpos=false;
			if(a[i]!=0) aallzero=false;
		}
		rep(i,m) cin>>p[i];
		// Solve Sped Cars @ Cameras
		rep(i,n)
		{
			rep(j,m)
			{
				int dx=p[j]-d[i];
				if(dx>=0 && dx<=x[i])
				{
					long double vt=sqrt(v[i]*v[i]+2*a[i]*dx);
					if(vt>V)
					{
						pc.insert(i);
						if(a[i]<0) pcp[j].pb(i);
						if(aallzero || aallpos) break;
					}
				}
			}
		}
		cout<<pc.size()<<" ";
		/*cerr<<"Sped Car Count="<<pc.size()<<", No.={";
		for(auto i:pc) cerr<<i<<",";
		cerr<<"}.\nFor each speedtester:\n";
		rep(i,m)
		{
			cerr<<"\t#"<<i<<":";
			for(auto j : pcp[i]) cerr<<j<<",";
			cerr<<endl;
		}*/
		//cerr<<aallzero<<" "<<aallpos<<endl;
		// Solve Closed Cameras
		if(pc.size()==0) {cout<<m<<endl; continue;}
		else if(aallzero || aallpos) {cout<<m-1<<endl; continue;}
		int must=1;
		bool checked[100005]={false};
		REP(i,1,m-1)
		{
			if(pcp[i]!=pcp[i-1])
			{
				if(pcp[i].size()<=pcp[i-1].size()) must++;
				else
				{
					for(auto j : pcp[i-1])
					{
						if(checked[j]) continue;
						bool found=false;
						for(auto k : pcp[i])
							if(k==j)
							{
								found=true;
								break;
							}
						if(!found)
						{
							must++;
							for(auto k:pcp[i-1]) checked[k]=true;
							break;
						}
					}
				}
			}
		}
		cout<<m-must<<endl;
	}
	return 0;
}
